<script>
import {getAward} from "@/api/work/award";
import {listAwardWinners} from "@/api/work/awardWinners";
import {listUser} from "@/api/system/user";

export default {
  name:"awardDetail",
  dicts: ['author_type', 'work_unit', 'unit_ranking', 'work_award_grade', 'work_award_level', 'sys_yes_no', 'sys_user_sex', 'subject_category', 'professional_title','education_backgorund','sys_yes_no','author_type','sys_user_sex'],
  props:{
    id:{
      type:String,
      required:true
    },
    // open:{
    //   type:Boolean,
    //   required: true,
    //   default:false
    // }
  },
  data () {
    return {
      size: '',
      // 获奖表格每行详情数据
      awardListDetail: {},
      awardWinnersList: [],
      awardWinnersData: {},
      baseUrl: process.env.VUE_APP_BASE_API,
      userList: [],
      fileList: [],
      loading:false,
    };
  },
  created() {

    this.getList();
  },

  methods: {
    urlList(){
      let temp = 1;
      const list = Array.isArray(this.awardListDetail.filesUrl) ? this.awardListDetail.filesUrl : this.awardListDetail.filesUrl.split(',');

      this.fileList = list.map(item => {
        // 获取最后一个'/'的位置
        const lastSlashIndex = item.lastIndexOf('/');
        if (typeof item === "string") {
          item = { name: item.slice(lastSlashIndex + 1), url: item };
        }
        item.uid = item.uid || new Date().getTime() + temp++;
        return item;
      });

    },
    /** 查询获奖列表详情页 */
    async getList() {
      getAward(this.id).then(async response => {
        this.awardListDetail = response.data;
        this.urlList()
        this.loading = false;
        this.userList = (await listUser()).rows;
          for (const item2 of this.userList) {
              if(this.awardListDetail.dataAddUserId == item2.userId) {
                this.awardListDetail.dataAddUserId = item2.nickName;
              }
          }


      });
      let res = (await listAwardWinners()).rows;
      for (const re of res) {
        if(re.workAwardId == this.id){
          this.awardWinnersList.push(re)
          if(re.signatureOrder=='1'){
            this.awardWinnersData = re;
          }

        }
      }
      this.loading = true;
    }

  },


}
</script>

<template>
  <div>
    <el-container>
      <el-header>获奖查看</el-header>
      <div>
        <el-tabs type="border-card">
          <el-tab-pane label="基本信息">
            <div class="body">
              <div class="jbxx">
                <el-tag>基本信息</el-tag>
                <el-descriptions class="margin-top" :column="2" :size="size" border>
                  <el-descriptions-item  :span="2">
                    <template slot="label">
                      获奖名称：
                    </template>
                    {{ awardListDetail.awardName }}
                  </el-descriptions-item>
                  <el-descriptions-item  :span="2">
                    <template slot="label">
                      第一完成人类型：
                    </template>
                    <dict-tag :options="dict.type.author_type" :value="awardWinnersData.authorType"/>
                  </el-descriptions-item>
                  <el-descriptions-item  :span="2">
                    <template slot="label">
                      第一完成人：
                    </template>
                    {{ awardListDetail.fistWinner }}
                  </el-descriptions-item>
                  <el-descriptions-item  :span="2">
                    <template slot="label">
                      成果名称：
                    </template>
                    {{ awardListDetail.resultName }}
                  </el-descriptions-item>
                  <el-descriptions-item  :span="2">
                    <template slot="label">
                      所属单位：
                    </template>

                    <dict-tag :options="dict.type.work_unit" :value="awardListDetail.affiliatedUnit"/>
                  </el-descriptions-item>
                  <el-descriptions-item>
                    <template slot="label">
                      获奖人数：
                    </template>
                    {{ awardListDetail.winnersNumber }}
                  </el-descriptions-item>
                  <el-descriptions-item>
                    <template slot="label">
                      发证机关：
                    </template>
                    {{ awardListDetail.licenceissuingAuthority }}
                  </el-descriptions-item>
                  <el-descriptions-item>
                    <template slot="label">
                      获奖日期：
                    </template>
                    {{ awardListDetail.awardDate }}
                  </el-descriptions-item>
                  <el-descriptions-item>
                    <template slot="label">
                      获奖级别：
                    </template>
                    <dict-tag :options="dict.type.work_award_level" :value="awardListDetail.awardLevel"/>
                  </el-descriptions-item>
                  <el-descriptions-item>
                    <template slot="label">
                      获奖等级：
                    </template>
                    <dict-tag :options="dict.type.work_award_grade" :value="awardListDetail.awardGrade"/>
                  </el-descriptions-item>
                  <el-descriptions-item>
                    <template slot="label">
                      获奖奖种：
                    </template>
                    {{ awardListDetail.pizeSpecies }}
                  </el-descriptions-item>
                  <el-descriptions-item>
                    <template slot="label">
                      完成单位：
                    </template>
                    {{ awardListDetail.completionUnit }}
                  </el-descriptions-item>
                  <el-descriptions-item>
                    <template slot="label">
                      是否论文征集：
                    </template>
                    <span v-if="awardListDetail.isCallForPapers==1">是</span>
                    <span v-if="awardListDetail.isCallForPapers==2">否</span>
                  </el-descriptions-item>
                  <el-descriptions-item>
                    <template slot="label">
                      总参加单位数量：
                    </template>
                    {{ awardListDetail.participationgUnitsNum }}
                  </el-descriptions-item>
                  <el-descriptions-item>
                    <template slot="label">
                      单位排名：
                    </template>
                    {{ awardListDetail.unitRanking }}
                  </el-descriptions-item>
                  <el-descriptions-item>
                    <template slot="label">
                      获奖批准号：
                    </template>
                    {{ awardListDetail.awardCode }}
                  </el-descriptions-item>
                  <el-descriptions-item>
                    <template slot="label">
                      学科门类：
                    </template>
                    <dict-tag :options="dict.type.subject_category" :value="awardListDetail.subjectCategoryId"/>
                  </el-descriptions-item>
                  <el-descriptions-item>
                    <template slot="label">
                      一级学科：
                    </template>
                    {{ awardListDetail.fistSubject }}
                  </el-descriptions-item>
                  <el-descriptions-item>
                    <template slot="label">
                      项目来源：
                    </template>
                    {{ awardListDetail.projectSource }}
                  </el-descriptions-item>
                  <el-descriptions-item>
                    <template slot="label">
                      成果形式：
                    </template>
                    {{ awardListDetail.resetForm }}
                  </el-descriptions-item>
                  <el-descriptions-item>
                    <template slot="label">
                      奖状类别：
                    </template>
                    <dict-tag :options="dict.type.work_award_level" :value="awardListDetail.awardLevel"/>
                  </el-descriptions-item>
                  <el-descriptions-item>
                    <template slot="label">
                      同意时间（秒）：
                    </template>
                    {{ parseTime(awardListDetail.dataAddDate, '{y}-{m}-{d} {h}:{i}:{s}') }}
                  </el-descriptions-item>
                </el-descriptions>
              </div>
              <div class="hjwcrxx">
                <el-tag>获奖完成人信息</el-tag>
<!--                <div v-for="item in awardWinnersList">-->
<!--                  <el-descriptions direction="vertical" :column="8" border >-->
<!--                    <el-descriptions-item label="署名顺序">{{ item.signatureOrder }}</el-descriptions-item>-->
<!--                    <el-descriptions-item label="作者类型"><dict-tag :options="dict.type.author_type" :value="item.authorType"/></el-descriptions-item>-->
<!--                    <el-descriptions-item label="完成人">{{ item.parsonCharge }}</el-descriptions-item>-->
<!--                    <el-descriptions-item label="性别"><dict-tag :options="dict.type.sys_user_sex" :value="item.gender"/></el-descriptions-item>-->
<!--                    <el-descriptions-item label="学历"><dict-tag :options="dict.type.education_backgorund" :value="item.educationBackgorund"/></el-descriptions-item>-->
<!--                    <el-descriptions-item label="职称"><dict-tag :options="dict.type.professional_title" :value="item.professionalTitle"/></el-descriptions-item>-->
<!--                    <el-descriptions-item label="工作单位"><dict-tag :options="dict.type.work_unit" :value="item.affiliatedUnit"/></el-descriptions-item>-->
<!--                    <el-descriptions-item label="贡献率">{{ item.contributionRate }}%</el-descriptions-item>-->
<!--                  </el-descriptions>-->
<!--                </div>-->
                <el-table :data="awardWinnersList" >
                  <el-table-column label="署名顺序" align="center" prop="signatureOrder" />
                  <el-table-column label="作者类型" align="center" prop="authorType" >
                    <template slot-scope="scope">
                      <dict-tag :options="dict.type.author_type" :value="scope.row.authorType"/>
                    </template>
                  </el-table-column>
                  <el-table-column label="完成人" align="center" prop="parsonCharge" />
                  <el-table-column label="性别" align="center" prop="gender" >
                    <template slot-scope="scope">
                      <dict-tag :options="dict.type.sys_user_sex" :value="scope.row.gender"/>
                    </template>
                  </el-table-column>
                  <el-table-column label="学历" align="center" prop="educationBackgorund" >
                    <template slot-scope="scope">
                      <dict-tag :options="dict.type.education_backgorund" :value="scope.row.educationBackgorund"/>
                    </template>
                  </el-table-column>
                  <el-table-column label="职称" align="center" prop="professionalTitle" >
                    <template slot-scope="scope">
                      <dict-tag :options="dict.type.professional_title" :value="scope.row.professionalTitle"/>
                    </template>
                  </el-table-column>
                  <el-table-column label="工作单位" align="center" prop="affiliatedUnit" >
                    <template slot-scope="scope">
                      <dict-tag :options="dict.type.work_unit" :value="scope.row.affiliatedUnit"/>
                    </template>
                  </el-table-column>
                  <el-table-column label="贡献率%" align="center" prop="contributionRate" >
                    <template slot-scope="scope">
                      <span>{{scope.row.contributionRate}}%</span>
                    </template>
                  </el-table-column>
                </el-table>
              </div>
              <div class="fjxx">
                <el-tag style="margin-top: 70px">附件信息</el-tag>
                <el-descriptions :column="1" :size="size" border>
                  <el-descriptions-item :span="2">
                      <template slot="label">
                        附件信息：
                      </template>
                    <div v-for="item in fileList">
                      <el-link style="color: red" :href=" '/dev-api'+item.url">{{item.name}}</el-link>
                    </div>
                  </el-descriptions-item>
                </el-descriptions>

              </div>
              <div class="bzxx">
                <el-tag>备注信息</el-tag>
                <el-descriptions class="margin-top" :column="1" :size="size" border>
                  <el-descriptions-item :span="2">
                    <template slot="label">
                      备注：
                    </template>
                    {{ awardListDetail.remark }}
                  </el-descriptions-item>
                </el-descriptions>
              </div>
              <div class="sjxx">
                <el-tag>数据信息</el-tag>
                <el-descriptions class="margin-top" :column="2" :size="size" border>
                  <el-descriptions-item>
                    <template slot="label">
                      新增人：
                    </template>
                    {{ awardListDetail.dataAddUserId }}
                  </el-descriptions-item>
                  <el-descriptions-item>
                    <template slot="label">
                      新增时间：
                    </template>
                    {{ parseTime(awardListDetail.dataAddDate, '{y}-{m}-{d}') }}

                  </el-descriptions-item>
                </el-descriptions>


              </div>
              <el-button class="gb" type="info" plain @click="handleClose">关闭</el-button>
            </div>
          </el-tab-pane>
          <el-tab-pane label="依托项目">
            <div class="body">
              依托项目(待开发)
            </div>
          </el-tab-pane>
        </el-tabs>
      </div>
    </el-container>
  </div>
</template>

<style scoped lang="scss">
.el-header, .el-footer {
  background-color: #B3C0D1;
  color: #333;
  text-align: left;
  line-height: 60px;
  font-weight: bold;
}
.el-main {
  color: #333;
  text-align: center;
  line-height: 160px;
  height: 100%;
}
.body {
  width: 100%;
  height: 1500px;
}
.jbxx {
  width: 100%;
  height: 650px;
}
.hjwcrxx {
  width: 100%;
  height: 150px;
}
.fjxx {
  width: 100%;
  height: 250px;
}
.sjxx {
  width: 100%;
  height: 200px;
}
.bzxx {
  width: 100%;
  height: 100px;
}
.gb {
  position: absolute;
  margin-left: 550px;
  width: 80px;
}
</style>
